package com.wxy.demo.service;

import com.wxy.demo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *
 * </p>
 *
 * @author e-Xiaoyuan.Wang
 * @since 2022/5/27 13:18
 */
@Service
@Transactional
public class UserService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void save(User user) {
        String sql = "insert into t_user(user_name,status) values(?,?)";
        jdbcTemplate.update(sql, user.getUserName(), user.getStatus());
        throw new RuntimeException("抛出一个异常");
    }
}
